import * as THREE from "three";

/**
 * 创建立方体
 * @param {number} width 宽度
 * @param {number} height 高度
 * @param {number} depth 深度
 * @param {number} angle 旋转角度（绕Y轴，-逆时针，+顺时针）
 * @param {object} material 材质
 * @param {number} x x轴坐标
 * @param {number} y y轴坐标
 * @param {number} z z轴坐标
 * @param {string} name 立方体名称
 * @param {number} translateX x轴平移距离
 * @param {number} trnaslateY y轴平移距离
 * @param {number} translateZ z轴平移距离
 * @returns {THREE.Mesh}
 */
export function buildCube(
  width,
  height,
  depth,
  angle,
  material,
  x,
  y,
  z,
  name,
  translateX = 0,
  trnaslateY = 0,
  translateZ = 0
) {
  const geometry = new THREE.BoxGeometry(width, height, depth);
  geometry.translate(translateX, trnaslateY, translateZ);
  var cube = new THREE.Mesh(geometry, material);
  cube.position.set(x, y, z);
  cube.rotation.y += angle * Math.PI; // -逆时针，+顺时针
  cube.name = name;
  return cube;
}
